home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / SOUND.SWG / 0038_Reading MODs.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  5KB  |  147 lines

  1. {
  2. -> Does anyone know how to read a .MOD file in pascal? Not play a .MOD
  3. -> just read all the pattern and track info. All the notes and stuff and
  4. -> effects. I dont care about the instrument data and all that.
  5. -> If so, could you please post a source or something?
  6.  
  7. I wrote a MOD sample ripper, thought about distributing it, it's rather
  8. nice.  I wrote it in TP.  I have some doc files on MOD's you might be
  9. interested in...
  10.  
  11. Subject: Amiga modules formaat
  12.  
  13.  Have you ever wondered how a Protracker 1.1B module is built up?
  14.  
  15.  Well, here's the...
  16.  
  17.  Protracker 1.1B Song/Module Format:
  18.  -----------------------------------
  19.  
  20.  Offset  Bytes  Description
  21.  ------  -----  -----------
  22.     0     20    Songname. Remember to put trailing null bytes at the
  23. end...
  24.  
  25.  Information for sample 1-31:
  26.  
  27.  Offset  Bytes  Description
  28.  ------  -----  -----------
  29.    20     22    Samplename for sample 1. Pad with null bytes.
  30.    42      2    Samplelength for sample 1. Stored as number of words.
  31.                 Multiply by two to get real sample length in bytes.
  32.    44      1    Lower four bits are the finetune value, stored as a
  33. signed
  34.                 four bit number. The upper four bits are not used, and
  35.                 should be set to zero.
  36.                 Value:  Finetune:
  37.                   0        0
  38.                   1       +1
  39.                   2       +2
  40.                   3       +3
  41.                   4       +4
  42.                   5       +5
  43.                   6       +6
  44.                   7       +7
  45.                   8       -8
  46.                   9       -7
  47.                   A       -6
  48.                   B       -5
  49.                   C       -4
  50.                   D       -3
  51.                   E       -2
  52.                   F       -1
  53.  
  54.    45      1    Volume for sample 1. Range is $00-$40, or 0-64 decimal.
  55.    46      2    Repeat point for sample 1. Stored as number of words
  56. offset
  57.                 from start of sample. Multiply by two to get offset in
  58. bytes.
  59.    48      2    Repeat Length for sample 1. Stored as number of words in
  60.                 loop. Multiply by two to get replen in bytes.
  61.  
  62.  Information for the next 30 samples starts here. It's just like the
  63. info for
  64.  sample 1.
  65.  
  66.  Offset  Bytes  Description
  67.  ------  -----  -----------
  68.    50     30    Sample 2...
  69.    80     30    Sample 3...
  70.     .
  71.     .
  72.     .
  73.   890     30    Sample 30...
  74.   920     30    Sample 31...
  75.  
  76.  Offset  Bytes  Description
  77.  ------  -----  -----------
  78.   950      1    Songlength. Range is 1-128.
  79.   951      1    Well... this little byte here is set to 127, so that old
  80.                 trackers will search through all patterns when loading.
  81.                 Noisetracker uses this byte for restart, but we don't.
  82.   952    128    Song positions 0-127. Each hold a number from 0-63 that
  83.                 tells the tracker what pattern to play at that position.
  84.  1080      4    The four letters "M.K." - This is something Mahoney &
  85. Kaktus
  86.                 inserted when they increased the number of samples from
  87.                 15 to 31. If it's not there, the module/song uses 15
  88. samples
  89.                 or the text has been removed to make the module harder
  90. to
  91.                 rip. Startrekker puts "FLT4" or "FLT8" there instead.
  92.  
  93. Offset  Bytes  Description
  94.  ------  -----  -----------
  95.  1084    1024   Data for pattern 00.
  96.     .
  97.     .
  98.     .
  99.  xxxx  Number of patterns stored is equal to the highest patternnumber
  100.        in the song position table (at offset 952-1079).
  101.  
  102.  Each note is stored as 4 bytes, and all four notes at each position in
  103.  the pattern are stored after each other.
  104.  
  105.  00 -  chan1  chan2  chan3  chan4
  106.  01 -  chan1  chan2  chan3  chan4
  107.  02 -  chan1  chan2  chan3  chan4
  108.  etc.
  109.  
  110.  Info for each note:
  111.  
  112.   _____byte 1_____   byte2_    _____byte 3_____   byte4_
  113.  /                \ /      \  /                \ /      \
  114.  0000          0000-00000000  0000          0000-00000000
  115.  
  116.  Upper four    12 bits for    Lower four    Effect command.
  117.  bits of sam-  note period.   bits of sam-
  118.  ple number.                  ple number.
  119.  
  120.  Periodtable for Tuning 0, Normal
  121.    C-1 to B-1 : 856,808,762,720,678,640,604,570,538,508,480,453
  122.    C-2 to B-2 : 428,404,381,360,339,320,302,285,269,254,240,226
  123.    C-3 to B-3 : 214,202,190,180,170,160,151,143,135,127,120,113
  124.  
  125.  To determine what note to show, scan through the table until you find
  126.  the same period as the one stored in byte 1-2. Use the index to look
  127.  up in a notenames table.
  128.  
  129.  This is the data stored in a normal song. A packed song starts with the
  130.  four letters "PACK", but i don't know how the song is packed: You can
  131.  get the source code for the cruncher/decruncher from us if you need it,
  132.  but I don't understand it; I've just ripped it from another tracker...
  133.  
  134.  In a module, all the samples are stored right after the patterndata.
  135.  To determine where a sample starts and stops, you use the sampleinfo
  136.  structures in the beginning of the file (from offset 20). Take a look
  137.  at the mt_init routine in the playroutine, and you'll see just how it
  138.  is done.
  139.  
  140.  Lars "ZAP" Hamre/Amiga Freelancers
  141.  
  142.  
  143. *** THE END ***
  144.  
  145. I believe that file goes under the name of MODFORM.DOC, not sure.  Not
  146. even sure where I got it.  Anyway, enjoy.
  147.